package com.iflytek.javase.base;

public class TestWhileAndForAndDowhile {

    public static void main(String[] args) {
        testWhileMethod();
        testDoWhileMethod();
        testForMethod();
    }

    public static void testWhileMethod() {
        int sum = 0;
        int i = 0;
        while (i <= 100) {
            sum = sum + i;
            i++;
        }
        System.out.println(sum);
    }

    public static void testDoWhileMethod() {

        int sum = 0;
        int i = 0;
        do {
            sum = sum + i;

            if (i == 4) {
                break;
            }
            i++;
        } while (i <= 100);
        System.out.println(sum);

    }

    public static void testForMethod() {
        int sum = 0;
        for (int i = 0; i <= 10; i++) {
            if (i == 50) {
                continue;
            }
            sum += i;
        }
        System.out.println(sum);
    }

}
